/**
 * Created by PanJiaChen on 16/11/18.
 */

/**
 * @param {string} path
 * @returns {Boolean}
 */
export function isExternal(path) {
  return /^(https?:|mailto:|tel:)/.test(path)
}

/**
 * @param {string} str
 * @returns {Boolean}
 */
export function validUsername(str) {
  // const valid_map = ['admin', 'editor']
  // return valid_map.indexOf(str.trim()) >= 0
  return str.length > 0
}
export const validRoleName = (rule, value, callback) => {
  if (!value) {
    return callback(new Error('用户姓名不能为空'))
  }
  setTimeout(() => {
    callback()
  }, 1000)
}
export const validRolCode = (rule, value, callback) => {
  if (!value) {
    return callback(new Error('用户代码不能为空'))
  }
  setTimeout(() => {
    callback()
  }, 1000)
}
